Law of cotangents